home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / mesa / mesa-glut / src-glut.aos / glutbitmap.c < prev    next >
C/C++ Source or Header  |  2000-02-23  |  2KB  |  53 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include "glutstuff.h"
  9. #include "glutBitmap.h"
  10.  
  11. void glutBitmapCharacter(GLUTbitmapFont font, int c)
  12. {
  13.   const BitmapCharRec *ch;
  14.   BitmapFontPtr fontinfo;
  15.   GLint swapbytes, lsbfirst, rowlength;
  16.   GLint skiprows, skippixels, alignment;
  17.  
  18.   fontinfo = (BitmapFontPtr) font;
  19.  
  20.   if (c < fontinfo->first ||
  21.     c >= fontinfo->first + fontinfo->num_chars)
  22.     return;
  23.   ch = fontinfo->ch[c - fontinfo->first];
  24.   if (ch) {
  25.     /* Save current modes. */
  26.     glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
  27.     glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
  28.     glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
  29.     glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
  30.     glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
  31.     glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
  32.     /* Little endian machines (DEC Alpha for example) could
  33.        benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
  34.        instead of GL_FALSE, but this would require changing the
  35.        generated bitmaps too. */
  36.     glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
  37.     glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
  38.     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
  39.     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
  40.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
  41.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  42.     glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
  43.       ch->advance, 0, ch->bitmap);
  44.     /* Restore saved modes. */
  45.     glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
  46.     glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
  47.     glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
  48.     glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
  49.     glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
  50.     glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
  51.   }
  52. }
  53.